import React, { Component } from 'react'
import Modal from './components/Modal';
export default class Test extends Component {
  state = {
    showModal: true
  }
  render () {
    return (
      <>


        {this.state.showModal ?
          (<Modal 
            bg='rgba(0,0,0,.7)' 
            opacity={0.8}
            onClose={()=>{
              this.setState({
                showModal: false
              })
            }}
          >

            <h1>蒙层</h1>
            <button onClick={
              () => {
                this.setState({
                  showModal: false
                })
              }
            }>关闭蒙层</button>
          </Modal>) : null}


        <button onClick={
          () => {
            this.setState({
              showModal: true
            })
          }
        }>显示蒙层</button>
      </>
    )
  }
}
